class Solution
{
public:
    bool isIsomorphic(string s, string t)
    {
        int len = s.size();
        for (int i = 0; i < len; ++i)
        {
            if (charMap.count(s[i]))
            {
                if (charMap[s[i]] != t[i])
                {
                    return false;
                }
            }
            else
            {
                if (mapped[t[i]])
                {
                    return false;
                }
                charMap[s[i]] = t[i];
                mapped[t[i]] = true;
            }
        }
        return true;
    }

    unordered_map<char, char> charMap;
    bool mapped[128];
};